package com.tinama.jedis01.enums;

/**
 * @author lgc
 * @createDate 2021/1/9 - 15:05
 */
public class Pizza {
    private PizzaStatus status;

    public enum PizzaStatus{
        ORDERED(5){
            @Override
            public boolean isOrdered()
            {
                return true;
            }
        },READY(2){
            @Override
            public boolean isReady()
            {
                return true;
            }
        },DELIVERED(0){
            @Override
            public boolean isDelivered()
            {
                return true;
            }
        };

        private int timeToDelivery;
        PizzaStatus(int timeToDelivery){
            this.timeToDelivery = timeToDelivery;
        }
        public boolean isOrdered() {return false;}
        public boolean isReady() {return false;}
        public boolean isDelivered(){return false;}
        public int getTimeToDelivery() {
            return timeToDelivery;
        }

    }
    public boolean isDeliverable() {
        return this.status.isReady();
    }

    public void printTimeToDeliver() {
        System.out.println("Time to delivery is " +
                this.getStatus().getTimeToDelivery());
    }



    public PizzaStatus getStatus() {
        return status;
    }

    public void setStatus(PizzaStatus status) {
        this.status = status;
    }
    public void deliver(){
        if (isDeliverable()){
            PizzaDeliveryStrategy.EXPRESS.deliver(this);
            this.setStatus(PizzaStatus.DELIVERED);
        }
    }
}
